package test12;

import net.sf.cglib.proxy.MethodProxy;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

/**
 * @Description TODO
 * @Author shallow
 * @Date 2023/4/16 16:54
 */

public class UserServiceInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        long start = System.currentTimeMillis();
        try {
            return methodInvocation.proceed();
        } finally {
            System.out.println("监控-Begin By Aop");
            System.out.println("method = " + methodInvocation.getMethod());
            System.out.println("方法耗时"+(System.currentTimeMillis()-start));
            System.out.println("监控 -End\r\n");
        }
    }
}
